{template 'web/common/common'}
{template 'web/system/navbar'}
<link rel="stylesheet" type="text/css" href="../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.css" />
<div class="panel panel-success">
    <div class="panel-heading">
        <h3 class="panel-title">
            微信公众号配置
        </h3>
    </div>

    <div class="panel-body">
        <form id="sign-form" class="form-horizontal" enctype="multipart/form-data" role="form" method="post" action="{url 'site/entry/system',array('m'=>'kundian_farm','op'=>'wx_set_save','version_id'=>$_GPC['version_id'])}" name="submit" style="padding: 20px 0;" >
            <input type="hidden" name="id" value="{$list['id']}">
            <div class="form-group">
                <label class="col-sm-2 control-label"></label>
                <div class="col-sm-8">
                    <span style="color: gray;">如需使用微信模板消息推送信息，请配置好微信公众号相关配置信息</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">微信公众号APPID</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control"  name="wx_appid" value="{$list['wx_appid']}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">微信公众号SECRET</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control"  name="wx_secret" value="{$list['wx_secret']}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">微信公众号模板消息ID（商城新订单通知）</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control"  name="wx_template_order_id" value="{$list['wx_template_order_id']}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label"></label>
                <div class="col-sm-8">
                    <span style="color: gray;">模板消息：搜索“新订单通知”=》编号：OPENTM200523662</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">微信公众号模板消息ID（种子、土地购买通知）</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control"  name="wx_shop_template_id" value="{$list['wx_shop_template_id']}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label"></label>
                <div class="col-sm-8">
                    <span style="color: gray;">模板消息：搜索“新订单通知”=》编号：OPENTM406199469</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">微信公众号通知模板消息ID（订单取消）</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control"  name="wx_cancel_template_id" value="{$list['wx_cancel_template_id']}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label"></label>
                <div class="col-sm-8">
                    <span style="color: gray;">模板消息：搜索“订单取消通知”=》编号：OPENTM406648164</span>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">微信支付证书CERT</label>
                <div class="col-sm-8">
                    <input type="file" class="form-control"  name="wx_cert" value="{$list['wx_cert']}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">微信支付证书KEY</label>
                <div class="col-sm-8">
                    <input type="file" class="form-control"  name="wx_key" value="{$list['wx_key']}">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">接收微信推送的openid</label>
                <div class="col-sm-8">
                    <!--<dvfdvbf="text" class="form-control" style="width: 400px;float: left;"  name="rank" value="{$list['rank']}">-->
                    {loop $wx_openid $index $item}
                    <span class="wx_openid_{$index}">{$item}</span>
                    <span class="deleteWxOpenid" data-wxid="{$index}" style="margin-left: 10px;color: red;cursor:pointer;">删除</span><br/>
                    {/loop}

                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">扫码绑定微信openid</label>
                <div class="col-sm-8">
                    <img style="width: 200px;height: 200px;" src="{url 'site/entry/system',array('m'=>'kundian_farm','op'=>'qcode','id'=>$list['id'],'version_id'=>$_GPC['version_id'])}" alt="">
                </div>
            </div>

            <div class="form-group">

                <div class="col-sm-offset-2 col-sm-10">
                    <button type="submit" class="btn btn-success">保存</button>
                    <!--<input type="submit" name="submit" class="btn btn-default">-->
                    <!--<a class="btn btn-default" href="{url 'site/entry/system',array('m'=>'kundian_farm')}">返回</a>-->
                </div>
            </div>

        </form>
    </div>
</div>

<script>
    require(["../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.js"],function(){
        $(function(){
            //删除
            $(".deleteWxOpenid").click(function(){
                var that=$(this);
                var id=$(this).attr('data-wxid');
                var shop_id=$("input[name='id']").val();
                swal({
                    title: '确定删除吗?',
                    text: "确定删除吗?",
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '删除',
                    cancelButtonText: '取消',
                }).then(function(isConfirm) {
                    if (isConfirm) {
                        $.ajax({
                            type:"post",
                            url:"{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'deleteOpenid','version_id'=>$_GPC['version_id'])}",
                            data:{id:id},
                            dataType:'json',
                            success:function(res){
                                if(res.status==1){
                                    swal('操作成功!', '操作成功!', 'success');
                                    that.remove();
                                    $(".wx_openid_"+id).remove();
                                }else{
                                    swal('操作失败!', '操作失败!', 'error');
                                }
                            }
                        })
                    }
                })
            });
        })
    })
</script>